/*
 * Created: 2022-08-29 21:17:45
 * Author : 涛涛涛
 */
import { myEnv } from '@/myEnv';
import { mergeRequest } from '@/utils';
import { Product_Web, Product_Res } from '@/pages/_server/_class/Product/Product';
/** 获得艺术品列表 */
export const apiGetProductList = async () => {
    const response1: MyResponse<Product_Res[]> = await sendRequest();
    const webData = response1.data.map((item) => {
        return new Product_Web().immit_response(item);
    });
    const resonlse2: MyResponse<Product_Web[]> = { ...response1, data: webData };
    return resonlse2;
};

const sendRequest = async () => {
    let response1: MyResponse<Product_Res[]>;
    if (myEnv.IS_ON_LINE) {
        response1 = await mergeRequest({
            url: 'goods',
            method: 'GET',
        });
    } else {
        response1 = {
            code: '200',
            message: 'ok',
            data: [
                {
                    id: '1',
                    artworkId: '1',
                    artistId: '1',
                    dropStartDate: '2022-10-02T06:00:00.000Z',
                    dropEndDate: '2022-10-02T06:30:00.000Z',
                    totalQuantity: '1000',
                    leftQuantity: '500',
                    price: '30.05',
                    status: 'waitForSale',
                },
                {
                    id: '2',
                    artworkId: '2',
                    artistId: '1',
                    dropStartDate: '2022-08-29T10:00:00.000Z',
                    dropEndDate: '2022-08-29T10:30:00.000Z',
                    totalQuantity: '100',
                    leftQuantity: '100',
                    price: '30.05',
                    status: 'dropping',
                },
                {
                    id: '3',
                    artworkId: '3',
                    artistId: '1',
                    dropStartDate: '2022-08-30T10:00:00.000Z',
                    dropEndDate: '2022-08-30T11:00:00.000Z',
                    totalQuantity: '3000',
                    leftQuantity: '3000',
                    price: '30.05',
                    status: 'soldOut',
                },
                {
                    id: '4',
                    artworkId: '4',
                    artistId: '1',
                    dropStartDate: '2022-08-30T07:00:00.000Z',
                    dropEndDate: '2022-08-30T07:30:00.000Z',
                    totalQuantity: '5000',
                    leftQuantity: '5000',
                    price: '30.05',
                    status: 'dropping',
                },
                {
                    id: '5',
                    artworkId: '5',
                    artistId: '1',
                    dropStartDate: '2022-08-30T07:00:00.000Z',
                    dropEndDate: '2022-08-30T07:30:00.000Z',
                    totalQuantity: '5000',
                    leftQuantity: '5000',
                    price: '30.05',
                    status: 'dropping',
                },
            ],
        };
    }
    return response1;
};
